import axios from 'axios'
const commonModule = {
    namespaced: true,
    state: () => ({
      oemConfig: localStorage.getItem('oemConfig') || {},
    }),
    getters: {
      getOemConfig() {
        return JSON.parse(localStorage.getItem('oemConfig'))
      }
    },
    mutations: {
      updateOemConfig(state, payload) {
        state.oemConfig = payload;
        localStorage.setItem('oemConfig', JSON.stringify(payload))
      },
    },
    actions: {
      async handleGetConfig({ commit }) {
        try {
            const res = await axios.get('/config.json');
            commit('updateOemConfig', res.data);
        } catch (error) {
            console.error("Error fetching config:", error);
        }
    }
    }
  }
  export default commonModule
  